package comm.jr.controller;

import comm.jr.entry.Standard;
import comm.jr.pojo.Page;
import comm.jr.service.StandardService;
import comm.jr.util.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController /*替换@RestController=@Controller + @ResponseBody*/
@RequestMapping("/st/")
public class StandardController {
    @Autowired
 private StandardService standardService;
    @Autowired
    private ResultObject result;
    @RequestMapping("getAll")
    public ResultObject getAll(Page page){
        System.out.println(page);
        int b=2;
        result.setResult(standardService.getAll(page.getPage(),b));
        return result;
    }
    @RequestMapping("getAllNumber")
    public Integer getAllNumber(){
        return standardService.getAllNumber();
    }
    @RequestMapping("remove")
    public String remove(Standard standard){
        return  standardService.deleteStandard(standard)==1?"删除成功":"删除失败";
    }
    @RequestMapping("change")
    public Integer change(Standard standard){
        return standardService.updateStandard(standard);

    }
    @RequestMapping("add")
    public Integer add(Standard standard){
        return standardService.insertStandard(standard);
    }
}
